package com.gdwhomework.chapter08.work005;

/**
 * @author 关道伟
 * @version 1.0
 */
public class Person {
    private String name;
    private Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }

    public Person(String name) {
        this.name = name;
    }

    public void passRiver(){
        if(!(vehicles instanceof Boat)){
            vehicles = Factory.get_boat();
        }
        vehicles.work();
    }

    public void common(){
        //如果工具不是马 就新new一个
        if(!(vehicles instanceof Horse)){
            vehicles = Factory.get_horse();
        }
        vehicles.work();
    }

    public void passFireMountain(){
        if(!(vehicles instanceof Airline)){
            vehicles = Factory.get_Arilen();
        }
        vehicles.work();
    }
}
